#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int ss(int n)
{
    if (1 != n % 2)
    {
        n = n / 2;
    }
    else
    {
        n = 3 * n + 1;
        n = n / 2;
    }
    return n;
}
void judge(int* p, int x)
{
    for (int a = 0; a < x; a++)
    {
        if (*(p + a) != 0)
        {
            int c = *(p + a);
            do
            {
                c = ss(c);
                for (int b = 0; b < x; b++)
                {
                    if (b != a)
                    {
                        if (*(p + b) == c)
                        {
                            *(p + b) = 0;
                        }
                    }
                }
            } while (c != 1);
        }
    }
}
int main()
{
    int x = 0;
    int arr[100] = { 0 };
    scanf("%d", &x);
    for (int i = 0; i < x; i++)
    {
        scanf("%d", &arr[i]);
    }
    judge(arr, x);
    int tmp = 0;
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < x - i; j++)
        {
            if (arr[j] < arr[j + 1])
            {
                tmp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = tmp;
            }
        }
    }
    int pcr[100];
    int m = 0;
    for (int i = 0; i < x; i++)
    {
        if (arr[i] != 0)
        {
            pcr[m++] = arr[i];
        }
    }
    for (int i = 0; i < m; i++)
    {
        if (i == m - 1)
        {
            printf("%d", arr[i]);
        }
        else
        {
            printf("%d ", arr[i]);
        }
    }
    return 0;
}